﻿<KCtl:BaseUserControl x:Class="Kiva7.Pages.PartnerDetailControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:KCtl="clr-namespace:Kiva7.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid>

        <ProgressBar Visibility="{Binding IsLoaded, Converter={StaticResource booleanToNotVisibility}}" 
                     IsIndeterminate="{Binding IsLoaded, Converter={StaticResource notBooleanConverter}}" 
                     Style="{StaticResource CustomIndeterminateProgressBar}"
                     VerticalAlignment="Center" />
        <ScrollViewer Visibility="{Binding IsLoaded, Converter={StaticResource booleanToVisibility}}" >
            <Grid Background="{StaticResource KivaBackgroundBrush}" DataContext="{Binding Partner}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition ></ColumnDefinition>
                    <ColumnDefinition MaxWidth="200" ></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <StackPanel Style="{StaticResource KivaPanelTextLargeStyle}" 
                            Grid.Row="0" Grid.ColumnSpan="2"  Margin="12,0,0,0">
                    <TextBlock Text="{Binding Name}" Style="{StaticResource KivaTextLargeStyle}"
                           TextWrapping="Wrap"/>
                </StackPanel>


                <StackPanel Grid.Row="1" Grid.Column="0" Style="{StaticResource KivaDetailStyle}">

                    <TextBlock Text="{Binding Path=L.StartDate, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                    <TextBlock Text="{Binding StartDate, Converter={StaticResource toShortDate}}" 
                                    Style="{StaticResource KivaTextAccentStyle}"
                                    Visibility="{Binding StartDate, Converter={StaticResource dateTimeVisibility}}"/>

                    <TextBlock Text="{Binding Path=L.Status, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding Status, Converter={StaticResource stringVisibility}}"/>
                    <TextBlock Text="{Binding Status, Converter={StaticResource loanStatus}}" 
                                       Visibility="{Binding Status, Converter={StaticResource stringVisibility}}"
                                       Style="{StaticResource KivaTextAccentStyle}"
                                       TextWrapping="Wrap"/>

                    <TextBlock Text="{Binding Path=L.Rating, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding Rating, Converter={StaticResource stringVisibility}}" />
                    <TextBlock Text="{Binding Rating}" 
                                       Style="{StaticResource KivaTextAccentStyle}"
                                       TextWrapping="Wrap"/>

                </StackPanel>
                <StackPanel Grid.Column="1" Grid.Row="1" >

                    <KCtl:KivaImageControl 
                        ImageSize="Normal"
                        ImageData="{Binding Image}" 
                           Width="200" Height="200" 
                           HorizontalAlignment="Right" VerticalAlignment="Top" 
                           Visibility="{Binding Image, Converter={StaticResource objectVisibility}}"/>

                    <StackPanel  Style="{StaticResource KivaDetailStyle}">
                        <TextBlock Text="{Binding Path=L.Loans, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                        <TextBlock Text="{Binding LoansPosted}" Style="{StaticResource KivaTextAccentStyle}"/>

                        <TextBlock Text="{Binding Path=L.Amount, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                        <TextBlock Text="{Binding TotalAmountRaisedUI, Converter={StaticResource toAmount}}" Style="{StaticResource KivaTextAccentStyle}"/>

                        <TextBlock Text="{Binding Path=L.DelinquencyRate, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                        <TextBlock Text="{Binding DelinquencyRateUI, Converter={StaticResource toPercentage}}" Style="{StaticResource KivaTextAccentStyle}"/>

                        <TextBlock Text="{Binding Path=L.DefaultRate, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                        <TextBlock Text="{Binding DefaultRateUI, Converter={StaticResource toPercentage}}" Style="{StaticResource KivaTextAccentStyle}"/>
                    </StackPanel>
                </StackPanel>
            </Grid>

        </ScrollViewer>
    </Grid>
</KCtl:BaseUserControl>
